home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / source / uOfflineProfile.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-03-26  |  2.0 KB  |  84 lines

  1. unit uOfflineProfile;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ComCtrls, TntComCtrls, IniFiles;
  8.  
  9. type
  10.   TfrmOfflineProfile = class(TForm)
  11.     Label1: TLabel;
  12.     TntListView1: TTntListView;
  13.     Button1: TButton;
  14.     Button2: TButton;
  15.     procedure TntListView1SelectItem(Sender: TObject; Item: TListItem;
  16.       Selected: Boolean);
  17.     procedure FormCreate(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.     function SelectedProfile: string;
  23.   end;
  24.  
  25. var
  26.   frmOfflineProfile: TfrmOfflineProfile;
  27.  
  28. implementation
  29.  
  30. uses
  31.   Unit1;
  32.  
  33. {$R *.dfm}
  34.  
  35. procedure TfrmOfflineProfile.TntListView1SelectItem(Sender: TObject;
  36.   Item: TListItem; Selected: Boolean);
  37. begin
  38.   Button1.Enabled := Selected;
  39.   Button1.Default := Selected;
  40. end;
  41.  
  42. procedure TfrmOfflineProfile.FormCreate(Sender: TObject);
  43. var
  44.   R: TSearchRec;
  45.   s: string;
  46. begin
  47.   if FindFirst(ExePath+'data\*.*',faDirectory,R) = 0 then
  48.     try
  49.       repeat
  50.         if (R.Name <> '') and (R.Name[1] <> '.') and
  51.           DirectoryExists(ExePath+'data\'+R.Name+'\dat') then
  52.           with TntListView1.Items.Add do begin
  53.             ImageIndex := 20;
  54.             Caption := R.Name;
  55.             SubItems.Add(R.Name);
  56.             Selected := AnsiCompareText(R.Name,Form1.PhoneIdentity) = 0;
  57.             Focused := Selected;
  58.             try
  59.               with TIniFile.Create(ExePath+'data\'+R.Name+'\dat\Phone.dat') do
  60.                 try
  61.                   s := ReadString('Global','PhoneName','');
  62.                   if s <> '' then Caption := s;
  63.                 finally
  64.                   Free;
  65.                 end;
  66.             except
  67.             end;
  68.           end;
  69.       until FindNext(R) <> 0;
  70.     finally
  71.       FindClose(R);
  72.     end;
  73. end;
  74.  
  75. function TfrmOfflineProfile.SelectedProfile: string;
  76. begin
  77.   if TntListView1.Selected <> nil then
  78.     Result := TntListView1.Selected.SubItems[0]
  79.   else
  80.     Result := '';
  81. end;
  82.  
  83. end.
  84.